package cn.lili.eventbus;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @Author Sylow
 * @Description 消息异步处理
 * @Date: Created in 14:19 2025/6/13
 */
@Configuration
@EnableAsync
public class AsyncConfig {

    @Bean("tradeEventExecutor")
    public Executor tradeEventExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.setMaxPoolSize(20);
        executor.setQueueCapacity(1000);
        executor.setThreadNamePrefix("trade-event-");
        executor.initialize();
        return executor;
    }
}
